var prefix = jsctx + "/shopGoods";

var shopNumber = (function () {
    function init(c) {

        setTimeout(function () {//防止先于-读取缓存执行

            load(c);

        }, 10)
    };

    $('#exampleTable').on('load-success.bs.table', function (e, data) {
        if (data.total && !data.rows.length) {
            $('#exampleTable').bootstrapTable('selectPage').bootstrapTable('refresh');
        }
    });
    var h = $(window).height() - 120;

    function load(c) {

        var transferType = $("#transferType").val();
        var isVerification = $("#isVerification").val();

        $('#exampleTable')
            .bootstrapTable(
                {
                    method: 'GET',
                    url: prefix + "/listPageHistory",
                    iconSize: 'outline',
                    toolbar: '#exampleToolbar',
                    striped: false,
                    dataType: "json",
                    pagination: true,
                    singleSelect: false,
                    // cache: false,
                    pageSize: 10,
                    pageList: [10, 20, 30],
                    pageNumber: 1,
                    sidePagination: "server",
                    paginationShowPageGo: true,
                    // contentType : "application/x-www-form-urlencoded",
                    // rightFixedColumns: true,
                    height: h,
                    queryParams: function (params) {

                        return {
                            limit: params.limit,
                            offset: (params.offset / params.limit) + 1,
                            shopOrderNum: $("#shopOrderNum").val().trim(),
                            stockRecordType: $("#stockRecordType").val().trim(),
                            // status: $("#status").val(),
                            startTime: $("#startTime").val().trim(),
                            endTime: $("#endTime").val().trim(),
                            shippingMobile:$("#shippingMobile").val().trim(),
                            goodsId: c
                        };
                    },
                    columns: [

                        {
                            title: '#', field: '', width: '50', align: 'center',
                            formatter: function (value, row, index) {
                                return index + 1;
                            }
                        },
                        {field: 'goodsNo', title: '商品编号', align: 'center', width: '100'},

                        {field: 'goodsName', title: '商品名称', width: '110', align: 'center'},

                        {
                            field: 'shopOrderNum', title: '订单号',
                            width: '80', align: 'center',

                        },
                        {field: 'nickname', title: '兑换人昵称', width: '80', align: 'center'},
                        {field: 'mobile', title: '兑换人手机号', width: '80', align: 'center'},
                        {field: 'createdTime', title: '变动时间', width: '80', align: 'center'},
                        {field: 'stockRecordType', title: '变动类型', width: '80', align: 'center',
                            formatter: function (value, row, index) {
                                if (value == '0') {
                                    return '商品发货'
                                }
                                else if(value == '1'){
                                    return '商品退货'
                                }
                                else if(value == '2'){
                                    return '后台减货'
                                }
                                else if(value == '3'){
                                    return '后台进货'
                                }
                            }
                        },
                        // {field: 'status', title: '变动状态', width: '80', align: 'center',
                        //     formatter: function (value, row, index) {
                        //         if(row.saleType=='3'){
                        //             return "补货成功"
                        //         }else if(row.saleType=='4'){
                        //             return "减货成功"
                        //         }
                        //         else{
                        //             if (value == '0') {
                        //                 return '未付款'
                        //             } else if (value == '1') {
                        //                 return '已付款未发货'
                        //             } else if (value == '2') {
                        //                 return '已发货'
                        //             }
                        //             else if(value == '3'){
                        //                 return '待使用'
                        //             }
                        //             else if(value == '4'){
                        //                 return '已经收货'
                        //             }
                        //             else if(value == '5'){
                        //                 return '退货申请中'
                        //             }
                        //             else if(value == '6'){
                        //                 return '等待退回'
                        //             }
                        //             else if(value == '7'){
                        //                 return '退货成功'
                        //             }
                        //         }
                        //
                        //
                        //     }
                        // },
                        { field:'variation',title: '变动数量', width: '80', align: 'center',
                        formatter:function (value,row,index) {
                              if(row.stockRecordType =='0'){
                                  return value*-1
                              }
                            else if(row.stockRecordType =='1'){
                                return value
                            }
                            else if (row.stockRecordType =='2'){
                                return value*-1
                            }
                            else{
                                return value
                            }
                        }},
                        {field: 'stockNum', title: '剩余库存', width: '80', align: 'center'},
                        {field: 'remark', title: '备注', width: '80', align: 'center'},
                        // {field: 'goodsNum', title: '本地实际库存变化', width: '80', align: 'center',
                        // formatter:function (value,row,index) {
                        //     if(row.saleType=='3'){
                        //         return value
                        //     }
                        //     else if(row.saleType=='4'){
                        //         return value*-1
                        //     }
                        //     else if (row.status =='7'||row.status =='0'||row.status =='1'){
                        //         return value
                        //     }
                        //     else{
                        //         return value*-1
                        //     }
                        // }},
                        {field: 'createdBy', title: '操作人', width: '100', align: 'center'},


                        // {field: 'remark', title: '失败原因', width: '100', align: 'left'},

                    ]
                });
    }
    function reLoad() {
        $(".fixed-table-header-columns").css("display", "none");
        $(".fixed-table-body-columns").css("display", "none");
        $('#exampleTable').bootstrapTable('refresh');
    }

    function addMemberRefundApply() {
        location.href = jsctx + "/templates/shopGoods/addShop.jsp"
    }

    function getMemberRefundApplyDetail(goodsId) {
        // location.href = prefix + "/listPageHistory/" + goodsId;
        // location.href = jsctx + "/templates/shopGoods/shopNumber.jsp?goodsId="+goodsId
        location.href =  prefix + "/listPageHistory";
    }

    var isajaxsendForPass = true;

    function updateStatusForPass(refundApplyId) {
        isajaxsendForPass = false;
        layer.confirm('确认处理此条申请？</br>(确认后请及时根据用户信息联系转账)', {
            btn: ['确定', '取消']
        }, function (index) {
            if (!isajaxsendForPass) {
                $.ajax({
                    url: prefix + "/updateMemberRefundApplyStatus",
                    type: "post",
                    data: {
                        'refundApplyId': refundApplyId,
                        'status': '1'
                    },
                    beforeSend: function () {
                        isajaxsendForPass = true;
                    },
                    success: function (data) {
                        isajaxsendForPass = true;
                        layer.close(index);
                        if (data.status == 200) {
                            layer.msg("处理成功");
                            reLoad();
                        } else {
                            isajaxsendForPass = true;
                            layer.msg(data.message);
                            reLoad();
                        }
                    }
                });
            }
        })
    }

    function updateStatusForPassVerification(refundApplyId) {

        if($('#isVerification').val() == '0'){
            $('#exampleModalVerification').modal('show')

            $("#submitVerificationForm").unbind("click").bind("click", function () {
                var formData = new FormData();
                formData.append("refundApplyId", refundApplyId);
                formData.append("status", "1");
                formData.append("authCode", $("#authCode").val());

                var isajaxVerification = true;

                if (isajaxVerification) {
                    $.ajax({
                        url: prefix + "/updateMemberRefundApplyStatus",
                        type: "post",
                        data: formData,
                        dataType: "json",
                        processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                        contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                        beforeSend: function () {
                            isajaxVerification = false;
                        },
                        success: function (data) {
                            if (data.status == 200) {
                                isajaxVerification = true;
                                parent.layer.msg("操作成功");
                                $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                    document.getElementById("contentFormVerification").reset();
                                })
                                $('#exampleModalVerification').modal('hide')
                                reLoad();
                            } else {
                                isajaxVerification = true;
                                parent.layer.alert(data.message);
                                $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                    document.getElementById("contentFormVerification").reset();
                                })
                                $('#exampleModalVerification').modal('hide')
                                reLoad();
                            }

                        }
                    })
                }

            })}
        if($('#isVerification').val() == '1'){
            var formData = new FormData();
            formData.append("refundApplyId", refundApplyId);
            formData.append("status", "1");
            var isajaxVerification = true;
            if (isajaxVerification) {
                $.ajax({
                    url: prefix + "/updateMemberRefundApplyStatus",
                    type: "post",
                    data: formData,
                    dataType: "json",
                    processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                    contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                    beforeSend: function () {
                        isajaxVerification = false;
                    },
                    success: function (data) {
                        if (data.status == 200) {
                            isajaxVerification = true;
                            parent.layer.msg("操作成功");
                            $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                document.getElementById("contentFormVerification").reset();
                            })
                            $('#exampleModalVerification').modal('hide')
                            reLoad();
                        } else {
                            isajaxVerification = true;
                            parent.layer.alert(data.message);
                            $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                document.getElementById("contentFormVerification").reset();
                            })
                            $('#exampleModalVerification').modal('hide')
                            reLoad();
                        }

                    }
                })
            }
        }
    }


    function updateStatusForOverrule(refundApplyId) {
        $('#exampleModal').modal('show')

        $("#submitForm").unbind("click").bind("click", function () {

            var formData = new FormData();
            formData.append("remark", $("#remark").val());
            formData.append("refundApplyId", refundApplyId);
            formData.append("status", "2");
            $.ajax({
                url: prefix + "/updateMemberRefundApplyStatus",
                type: "post",
                data: formData,
                dataType: "json",
                processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                success: function (data) {
                    if (data.status == 200) {
                        parent.layer.msg("操作成功");
                        $('#exampleModal').on('hidden.bs.modal', function () {
                            document.getElementById("contentForm").reset();
                        })
                        $('#exampleModal').modal('hide')
                        reLoad();
                    } else {
                        parent.layer.alert(data.message);
                        $('#exampleModal').on('hidden.bs.modal', function () {
                            document.getElementById("contentForm").reset();
                        })
                        $('#exampleModal').modal('hide')
                    }

                }
            })
        })
    }


    /*------  验证码  -----*/
    var num1 = 60;
    var ajaxReady = true;

    function getMemberRefundAuthCode() {
        if (ajaxReady) {
            $.ajax({
                url: prefix + "/getMemberRefundAuthCode",
                type: "POST",
                data: $('#authCode').val(),
                beforeSend: function () {
                    ajaxReady = false;
                },
                success: function (data) {
                    if (data.status == 200) {
                        time();

                        function time() {
                            if (num1 == 0) {
                                // $('#authCode').attr("disabled", "disabled")
                                $('#getMemberRefundAuthCode').text("获取验证码");
                                $('#getMemberRefundAuthCode').attr("onclick", 'memberRefundApply.getMemberRefundAuthCode()');
                                ajaxReady = true;
                                num1 = 60;
                            } else {
                                // $('#authCode').removeAttr('disabled')
                                $('#getMemberRefundAuthCode').html(num1 + "秒后重试");
                                $('#getMemberRefundAuthCode').removeAttr('onclick');
                                num1--;
                                setTimeout(function () {
                                    time()
                                }, 1000)
                            }
                        }
                    } else {
                        parent.layer.alert(data.message);
                        $('#authCode').removeAttr('disabled')
                        $('#getMemberRefundAuthCode').text("获取验证码");
                        $('#getMemberRefundAuthCode').attr("onclick", 'memberRefundApply.getMemberRefundAuthCode()');
                        ajaxReady = true;
                        num1 = 60;
                    }

                }
            })


        }
    };

    var isajaxsendForArrive = true;

    function updateStatusForArrive(refundApplyId) {
        if (isajaxsendForArrive) {
            layer.confirm('确认已到账？</br>(确认后将扣除用户余额中对应的提现金额，请确保用户余额充足且用户已收到您的退款)', {
                btn: ['确定', '取消']
            }, function (index) {

                $.ajax({
                    url: prefix + "/updateMemberRefundApplyStatus",
                    type: "post",
                    data: {
                        'refundApplyId': refundApplyId,
                        'status': '3'
                    },
                    beforeSend: function () {
                        isajaxsendForArrive = false;
                    },
                    success: function (data) {
                        isajaxsendForArrive = false;
                        setTimeout(function () {
                            isajaxsendForArrive = true;
                        }, 1500)
                        layer.close(index);
                        if (data.status == 200) {
                            layer.msg("操作成功");
                            reLoad();
                        } else {
                            layer.msg(data.message);
                        }
                    }
                });

            })
        }
    }

    function goBack() {
        window.history.back();
    }

    function exportMemberRefundApply() {
        $.fileDownload(prefix + "/exportMemberRefundApply", { // 后台请求链接
            httpMethod: "get",　　　　　　　　// 请求方式
            contentType: 'application/json',　 // 请求头
            data: {　　　　　　　　　　　　　　　// 参数，左边为后台接收的参数名，右边为前端获取的值，
                nickname: $("#nickname").val().trim(),
                mobile: $("#mobile").val().trim(),
                refundSource: $("#refundSource").val().trim(),
                outTradeNo: $("#outTradeNo").val().trim(),
                refundBy: $("#refundBy").val().trim(),
                memberMobile: $("#memberMobile").val().trim(),
                memberRealName: $("#memberRealName").val().trim(),
                status: $("#status").val().trim(),
                startTime: $("#startTime").val().trim(),
                endTime: $("#endTime").val().trim(),
                count: $("#count").val().trim() == '' ? 0 : $("#count").val().trim(),
                offset: $('.active .page-link').text(),
                limit: $(".page-size").text()
            },
            prepareCallback: function (url) {
                layer.msg("文件下载中...", {time: -1})
            },
            abortCallback: function (url) {
                // 异常终止
                layer.msg("文件下载异常！！");
            },
            successCallback: function (url) {
                layer.msg("文件下载成功！！", {time: 1500});
            },
            failCallback: function (data) {
                var str = "{" + data.substring(data.indexOf("{") + 1, data.indexOf("}")) + "}";
                layer.msg(JSON.parse(str).message);
            }
        })
    }
    function pdselect(){
        var rows = $("#exampleTable").bootstrapTable('getSelections');// 获得要删除的数据
        if (rows.length == 0) {// rows 主要是为了判断是否选中，下面的else内容才是主要
            alert("请先选择要处理的订单!");
            return;
        } else {
            var memberIds = new Array();// 声明一个数组
            var refundAmounts = new Array();
            var refundApplyIds = new Array();
            $(rows).each(function () {// 通过获得别选中的来进行遍历
                memberIds.push(this.memberId); // cid为获得到的整条数据中的一列
                refundAmounts.push(this.refundAmount);
                refundApplyIds.push(this.refundApplyId);
            });
            let sum = 0;
            for (let i=0;i<refundAmounts.length;i++){
                sum = sum + refundAmounts[i];
            }
            memberIdList = JSON.stringify(memberIds);
            refundApplyIdList = JSON.stringify(refundApplyIds);
            memberAdd(memberIdList,memberIds,sum,refundApplyIdList)
        }
    }
    function memberAdd(a,b,c,d) {
        isajaxsendForPass = false;
        var number = b.length;
        // var money = c;
        // var money = Math.round(Math.round((c*100)/100));
        var money = Math.floor(c*100) / 100;
        layer.open({
                title:'批量处理',
                area:['300px','200px'],
                content:'勾选数量:'+ number + '</br>'+ '需退款金额:' + money,
                // + '</br>' + '备注:' + '</br>' + '<textarea id="sefix" rows="4" cols="33"></textarea>'
                btn: ['取消','批量处理','批量驳回',],
                yes:function(index,layero){
                    layer.close(index);
                },

                btn2:function(index,layero){
                    // console.log($('#isVerification').val());
                    if($('#isVerification').val() == '0')
                    { $('#exampleModalVerification').modal('show');
                        // console.log($("#sefix").val());
                        // var text = $("#sefix").val();
                        $("#submitVerificationForm").unbind("click").bind("click", function () {
                            var formData = new FormData();
                            formData.append("refundApplyIdsJson",d);
                            formData.append("status", "1");
                            formData.append("authCode", $("#authCode").val());
                            // formData.append("remark", text);
                            var isajaxVerification = true;

                            if (isajaxVerification) {
                                $.ajax({
                                    url: prefix + "/batchUpdateMemberRefundApplyStuts",
                                    type: "post",
                                    data: formData,
                                    dataType: "json",
                                    processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                                    contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                                    beforeSend: function () {
                                        isajaxVerification = false;
                                    },
                                    success: function (data) {
                                        // if (data.status == 200 && data.message == null) {
                                        //     isajaxVerification = true;
                                        //     parent.layer.msg("操作成功");
                                        //     $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                        //         document.getElementById("contentFormVerification").reset();
                                        //     })
                                        //     $('#exampleModalVerification').modal('hide')
                                        //     reLoad();
                                        //
                                        // }else if (data.status == 200 && data.message != null){
                                        //     // parent.layer.msg("data");
                                        //     $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                        //         document.getElementById("contentFormVerification").reset();
                                        //     })
                                        //     $('#exampleModalVerification').modal('hide')
                                        //     layer.open({
                                        //         title:'信息提示',
                                        //         area:['300px','300px'],
                                        //         content:data.message,
                                        //         btn: ['确定'],
                                        //         success:function () {
                                        //              reLoad();
                                        //         }
                                        //
                                        // })}
                                        // else {
                                        //     isajaxVerification = true;
                                        //     parent.layer.alert(data.message);
                                        //     $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                        //         document.getElementById("contentFormVerification").reset();
                                        //     })
                                        //     $('#exampleModalVerification').modal('hide')
                                        //     reLoad();
                                        // }
                                        if (data.status == 200 && data.message == "") {
                                            isajaxVerification = true;
                                            parent.layer.msg("操作成功");
                                            $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                                document.getElementById("contentFormVerification").reset();
                                            })
                                            $('#exampleModalVerification').modal('hide');
                                            reLoad();
                                        }
                                        else if(data.status == 200 && data.message != ""){
                                            isajaxVerification = true;
                                            // parent.layer.msg("操作成功");
                                            $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                                document.getElementById("contentFormVerification").reset();
                                            });
                                            $('#exampleModalVerification').modal('hide');
                                            layer.open({
                                                title:'信息提示',
                                                area:['300px','200px'],
                                                content:data.message,
                                                btn: ['确定']

                                            });
                                            reLoad();
                                        }else {
                                            isajaxVerification = true;
                                            parent.layer.alert(data.message);
                                            $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                                document.getElementById("contentFormVerification").reset();
                                            });
                                            $('#exampleModalVerification').modal('hide');
                                            reLoad();
                                        }

                                    }
                                })
                            }

                        })}
                    if($('#isVerification').val() == '1'){
                        var formData = new FormData();
                        formData.append("refundApplyIdsJson",d);
                        formData.append("status", "1");
                        var isajaxVerification = true;
                        if (isajaxVerification) {
                            $.ajax({
                                url: prefix + "/batchUpdateMemberRefundApplyStuts",
                                type: "post",
                                data: formData,
                                dataType: "json",
                                processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                                contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                                beforeSend: function () {
                                    isajaxVerification = false;
                                },
                                success: function (data) {
                                    if (data.status == 200 && data.message == "") {
                                        isajaxVerification = true;
                                        parent.layer.msg("操作成功");
                                        $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                            document.getElementById("contentFormVerification").reset();
                                        })
                                        $('#exampleModalVerification').modal('hide');
                                        reLoad();
                                    }
                                    else if(data.status == 200 && data.message != ""){
                                        isajaxVerification = true;
                                        // parent.layer.msg("操作成功");
                                        $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                            document.getElementById("contentFormVerification").reset();
                                        })
                                        $('#exampleModalVerification').modal('hide');
                                        layer.open({
                                            title:'信息提示',
                                            area:['300px','200px'],
                                            content:data.message,
                                            btn: ['确定']

                                        });
                                        reLoad();
                                    }
                                    else {
                                        isajaxVerification = true;
                                        parent.layer.alert(data.message);
                                        $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                            document.getElementById("contentFormVerification").reset();
                                        })
                                        $('#exampleModalVerification').modal('hide')
                                        reLoad();
                                    }
                                }
                            })}}

                },
                btn3:function(index,layero){

                    $('#exampleModal').modal('show')

                    $("#submitForm").unbind("click").bind("click", function () {

                        var formData = new FormData();
                        formData.append("remark", $("#remark").val());
                        formData.append("refundApplyIdsJson",d);
                        formData.append("status", "2");
                        $.ajax({
                            url: prefix + "/batchUpdateMemberRefundApplyStuts",
                            type: "post",
                            data: formData,
                            dataType: "json",
                            processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                            contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                            success: function (data) {
                                if (data.status == 200 && data.message == "") {
                                    // layer.msg("操作成功");
                                    parent.layer.msg("操作成功");
                                    $('#exampleModal').on('hidden.bs.modal', function () {
                                        document.getElementById("contentForm").reset();
                                    })
                                    $('#exampleModal').modal('hide')
                                    reLoad();
                                }
                                else if(data.status == 200 && data.message != "")
                                {
                                    // layer.msg("请填写备注");
                                    $('#exampleModal').on('hidden.bs.modal', function () {
                                        document.getElementById("contentForm").reset();
                                    })
                                    $('#exampleModal').modal('hide')
                                    layer.open({
                                        title:'信息提示',
                                        area:['300px','200px'],
                                        content:data.message,
                                        btn: ['确定']

                                    })
                                    reLoad();

                                }
                                else {
                                    // layer.msg('操作失败');
                                    parent.layer.alert(data.message);
                                    $('#exampleModal').on('hidden.bs.modal', function () {
                                        document.getElementById("contentForm").reset();
                                    })
                                    $('#exampleModal').modal('hide')
                                    reLoad();
                                }

                            }
                        })
                    })


                }
            }

        )
    }

    return {
        init: init,
        goBack: goBack,
        reLoad: reLoad,
        updateStatusForPass: updateStatusForPass,
        updateStatusForOverrule: updateStatusForOverrule,
        addMemberRefundApply: addMemberRefundApply,
        getMemberRefundApplyDetail: getMemberRefundApplyDetail,
        updateStatusForArrive: updateStatusForArrive,
        exportMemberRefundApply: exportMemberRefundApply,
        updateStatusForPassVerification: updateStatusForPassVerification,
        getMemberRefundAuthCode: getMemberRefundAuthCode,
        memberAdd: memberAdd,
        pdselect:pdselect
    };
})();

// var shopNumber = (function () {
//     function init() {
//         validateRule();
//     };
//
//     function getCheckedRoles() {
//         var adIds = "";
//         $("input:checkbox[name=role]:checked").each(function (i) {
//             if (0 == i) {
//                 adIds = $(this).val();
//             } else {
//                 adIds += ("," + $(this).val());
//             }
//         });
//         return adIds;
//     }
//
//     var isajaxsend = true;
//
//     function save() {
//         if ($("select[name='refundBy']").val() == "2") {
//             if ($("select[name='refundBankCode']").val() == "" || $("select[name='refundBankCode']").val() == null) {
//                 var str = "<label class='error couponError' ><i class='fa fa-times-circle'></i>请选择银行</label>"
//                 $(".refundBankCodeDiv").append(str)
//                 return;
//             }
//         }
//
//
//         if (isajaxsend) {
//             var formData = new FormData($("#frmMemberRefundApply")[0]);
//             $("#roleIds").val(getCheckedRoles());
//             $.ajax({
//                 cache: true,
//                 type: "POST",
//                 url: prefix + "/saveMemberRefundApply",
//                 data: formData,
//                 processData: false,
//                 contentType: false,
//                 async: false,
//                 beforeSend: function () {
//                     isajaxsend = false
//                 },
//                 error: function (request) {
//                     isajaxsend = true
//                     parent.layer.alert("Connection error");
//                 },
//                 success: function (data) {
//                     if (data.status == 200) {
//                         isajaxsend = false
//                         parent.layer.msg("操作成功");
//                         window.history.back();
//                     } else {
//                         isajaxsend = true
//                         parent.layer.alert(data.message)
//                     }
//
//                 }
//             });
//         }
//     }
//
//     function validateRule() {
//         var icon = "<i class='fa fa-times-circle'></i> ";
//         $("#frmMemberRefundApply").validate({
//             rules: {
//                 // memberMobile: {
//                 //     required: true
//                 // },
//                 // memberRealName: {
//                 //     required: true
//                 // },
//                 refundAmount: {
//                     required: true,
//                     min: 1
//                 },
//                 refundSource: {
//                     required: true,
//                 },
//
//             },
//             messages: {
//                 // memberMobile: {
//                 //     required: icon + "请输入提现账户号码"
//                 // },
//                 // memberRealName: {
//                 //     required: icon + "请输入真实姓名"
//                 // },
//                 refundAmount: {
//                     required: icon + "请输入退款金额",
//                     min: icon + "请输入大于1的金额",
//                 },
//                 refundSource: {
//                     required: icon + "请选择用户充电端",
//                 },
//             },
//             submitHandler: function (form) {
//                 save();
//             }
//         })
//     }
//
//     return {
//         init: init
//     };
// })();
